#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2020-05-07 11:50
# @Author  : Sunnn
# @File    : LogosDataDianShangModel.py
# @Software: PyCharm
# @intro   :
import re
import time
import warnings
from typing import Union

from pydantic import BaseModel, Field, validator
from pydantic.utils import ValueItems

try:
    from .LogosDataBaseModel import LogosDataDianShangModel
except ImportError:
    from LogosDataBaseModel import LogosDataDianShangModel


class LgGood(LogosDataDianShangModel):
    """
        商品验证模型 ----------------------------------------------------------------------------------------------------

        字段名称      字段中文名称                      数据类型  取值规范                    是否分区    是否可空        备注
        ---------------------------------------------------------------------------------------------------------------
        dpid	    店铺ID	                        string	[0-9a-zA-Z-_]			                否
        spid	    商品ID	                        string	[0-9a-zA-Z]			                    否
        yhid	    用户id	                        string				                            是
        url	        商品链接	                        string	http/https			                    否
        yxl	        月销量	                        string	[0-9]			                        是
        zxl	        总销量	                        string	[0-9]			                        是
        spdj	    商品单价                          string	[0-9].[0-9]			                    是
        spdj_max	商品最大价格	                    string	[0-9].[0-9]			                    是
        spdj_min	商品最小价格	                    string	[0-9].[0-9]			                    是
        splx	    商品类型（ 0：异常商品  1:正常商品）	string	(0|1)			                        是
        spmc	    商品名称	                        string	不含不可见字符，头尾无空格	                否
        sphpl	    商品好评率	                    string	[0,100.0]			                    是
        spppmc  	品牌名称	                        string	头尾无空格			                    是
        spppid	    品牌id	                        string				                            是
        spflid	    类目id	                        string				                            是
        spflid_1	一级类目id	                    string				                            是
        spflid_2	二级类目id	                    string				                            是
        cjsj	    采集时间	                        string	YYYY-MM-DD HH:MM:SS			            否
        scsjsj	    首次上架时间	                    string	YYYY-MM-DD			                    是      2020/04/27新增

    """
    dpid: str = Field()
    spid: str = Field()
    yhid: str = Field(default='')
    url: str = Field()
    yxl: str = Field(default='')
    zxl: str = Field(default='')

    spdj: str = Field(default='')
    spdj_max: str = Field(default='')
    spdj_min: str = Field(default='')
    splx: str = Field(default='')
    spmc: str = Field()
    sphpl: str = Field(default='')
    spppmc: str = Field(default='')
    spppid: str = Field(default='')
    spflid: str = Field(default='')
    spflid_1: str = Field(default='')
    spflid_2: str = Field(default='')
    cjsj: str = Field()
    scsjsj: str = Field(default='')

    @validator('dpid')
    def dpid_must_string(cls, v):
        if not re.match('([0-9a-zA-Z-_]+)', v):
            raise ValueError('dpid value must be 0-9a-zA-Z-_')
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('spid')
    def spid_must_string(cls, v):
        if not re.match('([0-9a-zA-Z]+)', v):
            raise ValueError('spid value must be 0-9a-zA-Z')
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('yhid')
    def yhid_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('url')
    def url_must_string(cls, v):
        if 'http://' not in v and 'https://' not in v:
            raise ValueError('url value must have http/https')

        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('yxl')
    def yxl_must_string(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('yxl value must be int')
        if v < 0:
            raise ValueError('yxl value must be greater than or equal to zero')
        return str(v)

    @validator('zxl')
    def zxl_must_string(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('zxl value must be int')
        if v < 0:
            raise ValueError('zxl value must be greater than or equal to zero')
        return str(v)

    @validator('spdj')
    def spdj_must_float_string(cls, v):
        try:
            v = round(float(v), 2)
        except ValueError:
            raise ValueError('spdj value must be float')
        if v < 0:
            raise ValueError(' value must be greater than or equal to zero')
        return str(v)

    @validator('spdj_max')
    def spdj_max_must_float_string(cls, v):
        try:
            v = round(float(v), 2)
        except ValueError:
            raise ValueError('spdj_max value must be float')
        if v < 0:
            raise ValueError('spdj_max value must be greater than or equal to zero')
        return str(v)

    @validator('spdj_min')
    def spdj_min_must_int_string(cls, v):
        try:
            v = round(float(v), 2)
        except ValueError:
            raise ValueError('spdj_min value must be float')
        if v < 0:
            raise ValueError('spdj_min value must be greater than or equal to zero')
        return str(v)

    @validator('splx')
    def splx_must_int_string(cls, v):
        if v not in ['1', '0']:
            raise ValueError('splx value must be zero or one')
        return str(v)

    @validator('spmc')
    def spmc_must_int_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('sphpl')
    def sphpl_must_float_string(cls, v):
        v = float(v)
        if v < 0 or v > 100:
            raise ValueError('sphpl value must be greater than or equal to zero and Less than one hundred')
        return str(v)

    @validator('spppmc')
    def spppmc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('spppid')
    def spppid_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('spflid')
    def spflid_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('spflid_1')
    def spflid_1_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('spflid_2')
    def spflid_2_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('cjsj')
    def cjsj_must_string(cls, v):
        time.strptime(v, "%Y-%m-%d %H:%M:%S")
        return str(v)

    @validator('scsjsj')
    def scsjsj_must_string(cls, v):
        time.strptime(v, "%Y-%m-%d")
        return str(v)


class LgShop(LogosDataDianShangModel):
    """
        店铺验证模型 ----------------------------------------------------------------------------------------------------

        字段名称      字段中文名称                      数据类型  取值规范                    是否分区    是否可空        备注
        ---------------------------------------------------------------------------------------------------------------
        dpid        店铺id	                        string	[0-9a-zA-Z-_]			                否
        url	        店铺链接	                        string	http/https			                    否
        dpmc	    店铺名称	                        string	不含不可见字符（空格除外），头尾无空格			否
        dpszsfmc	店铺所在省份名称	                string	省份名称（eg：北京），不含不可见字符			是
        dpszcsmc	店铺所在城市名称	                string	城市名称（eg：深圳市），不含不可见字符			是
        dpdz	    店铺地址	                        string	头尾无空格			                    是

        zybz	    自营标志（其它：0  自营：1）	        string	(0|1)			                        否
        qydpbz	    企业店铺标志（其它：0  企业店铺：1）	string	(0|1)			                        否
        kdsj	    开店时间	                        string	YYYY-MM-DD			                    是
        qymc	    企业名称	                        string	中文状态括号，不含不可见字符，头尾无空格	    是
        dppf	    店铺评分	                        string	[0,10.0]			                    是
        spbj	    商品与同行业相比	                string	正负数，表示的是百分比			            是
        sppf	    商品评分	                        string	[0,10.0]			                    是
        wlbj	    物流与同行业相比	                string	正负数，表示的是百分比			            是
        wlpf	    物流评分	                        string	[0,10.0]			                    是
        fwbj	    服务与同行业相比	                string	正负数，表示的是百分比			            是
        fwpf	    服务评分	                        string	[0,10.0]			                    是
        cjsj	    采集时间	                        string	YYYY-MM-DD HH:MM:SS			            否
        dpzt	    店铺状态（0：开店  1：关店）	        string	(0|1)			                        是	2020/04/27新增
        qydz	    企业地址	                        string	头尾无空格			                    是
        yhid	    用户ID	                        string				                            是	2020/04/29新增

    """
    dpid: str = Field()
    url: str = Field()
    dpmc: str = Field()
    dpszsfmc: str = Field(default='')
    dpszcsmc: str = Field(default='')
    dpdz: str = Field(default='')

    zybz: str = Field()
    qydpbz: str = Field()

    kdsj: str = Field(default='')
    qymc: str = Field(default='')
    dppf: str = Field(default='')
    spbj: str = Field(default='')
    sppf: str = Field(default='')
    wlbj: str = Field(default='')
    wlpf: str = Field(default='')
    fwbj: str = Field(default='')
    fwpf: str = Field(default='')

    cjsj: str = Field()

    dpzt: str = Field(default='')
    qydz: str = Field(default='')
    yhid: str = Field(default='')

    @validator('dpid')
    def dpid_must_string(cls, v):
        if not re.match('([0-9a-zA-Z-_]+)', v):
            raise ValueError('dpid value must be 0-9a-zA-Z-_')
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('url')
    def url_must_string(cls, v):
        if 'http://' not in v and 'https://' not in v:
            raise ValueError('url value must have http/https')

        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('dpmc')
    def dpmc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('dpszsfmc')
    def dpszsfmc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('dpszcsmc')
    def dpszcsmc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('dpdz')
    def dpdz_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('zybz')
    def zybz_must_string(cls, v):
        if v not in ['1', '0']:
            raise ValueError('splx value must be zero or one')
        return str(v)

    @validator('qydpbz')
    def qydpbz_must_string(cls, v):
        if v not in ['1', '0']:
            raise ValueError('splx value must be zero or one')
        return str(v)

    @validator('kdsj')
    def kdsj_must_string(cls, v):
        time.strptime(v, "%Y-%m-%d")
        return str(v)

    @validator('qymc')
    def qymc_must_string(cls, v):
        new_v = v.replace('(', '（').replace(')', '）').replace(',', ' ').replace('，', '').replace("'", '').replace('"',
                                                                                                                  '').replace(
            ' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('dppf')
    def dppf_must_string(cls, v):
        v = round(float(v), 1)
        if v < 0 or v > 10:
            raise ValueError('dppf value must be greater than or equal to zero and Less than one hundred')
        return str(v)

    @validator('spbj')
    def spbj_must_string(cls, v):
        v = float(v)
        return str(v)

    @validator('sppf')
    def sppf_must_string(cls, v):
        v = round(float(v), 1)
        if v < 0 or v > 10:
            raise ValueError('sppf value must be greater than or equal to zero and Less than one hundred')
        return str(v)

    @validator('wlbj')
    def wlbj_must_string(cls, v):
        v = float(v)
        return str(v)

    @validator('wlpf')
    def wlpf_must_string(cls, v):
        v = round(float(v), 1)
        if v < 0 or v > 10:
            raise ValueError('wlpf value must be greater than or equal to zero and Less than one hundred')
        return str(v)

    @validator('fwbj')
    def fwbj_must_string(cls, v):
        v = float(v)
        return str(v)

    @validator('fwpf')
    def fwpf_must_string(cls, v):
        v = round(float(v), 1)
        if v < 0 or v > 10:
            raise ValueError('fwpf value must be greater than or equal to zero and Less than one hundred')
        return str(v)

    @validator('cjsj')
    def cjsj_must_string(cls, v):
        time.strptime(v, "%Y-%m-%d %H:%M:%S")
        return str(v)

    @validator('dpzt')
    def dpzt_must_string(cls, v):
        if v not in ['1', '0']:
            raise ValueError('dpzt value must be zero or one')
        return str(v)

    @validator('qydz')
    def qydz_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('yhid')
    def yhid_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v


class LgCompany(LogosDataDianShangModel):
    """
        公司验证模型 ----------------------------------------------------------------------------------------------------

        字段名称      字段中文名称                      数据类型  取值规范                    是否分区    是否可空        备注
        ---------------------------------------------------------------------------------------------------------------
        qymc	    企业名称	                        string	不含不可见字符（空格除外）		            否
        dpqymc	    店铺企业名称	                    string	不含不可见字符（空格除外）		            否
        shxydm	    统一社会信用代码	                string	[0-9a-zA-Z]			                    是
        fddbr	    法定代表人	                    string				                            否
        jyzt	    经营状态	                        string				                            是
        clrq	    成立日期	                        string	YYYY-MM-DD			                    否
        yyqx	    营业期限	                        string	头尾无空格			                    否
        zczb	    注册资本	                        string				                            是
        qylx	    企业类型                        	string				                            是
        xzqhsfmc	行政区划省份名称	                string	省份名称（eg：北京）			            否
        xzqhcsmc	行政区划城市名称	                string	城市名称（eg：深圳市）			            否
        zcdz	    注册地址	                        string				                            否
        jyfw	    经营范围	                        string				                            是
        cjsj	    采集时间	                        string	YYYY-MM-DD HH:MM:SS			            否
    """
    qymc: str = Field()
    dpqymc: str = Field()
    shxydm: str = Field(default='')
    fddbr: str = Field()
    jyzt: str = Field(default='')
    clrq: str = Field()
    yyqx: str = Field()
    zczb: str = Field(default='')
    qylx: str = Field(default='')
    xzqhsfmc: str = Field()
    xzqhcsmc: str = Field()
    zcdz: str = Field()
    jyfw: str = Field(default='')
    cjsj: str = Field()

    @validator('qymc')
    def qymc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('dpqymc')
    def dpqymc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('shxydm')
    def shxydm_must_string(cls, v):
        if not re.match('([0-9a-zA-Z]+)', v):
            raise ValueError('shxydm value must be 0-9a-zA-Z')
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('fddbr')
    def fddbr_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('jyzt')
    def jyzt_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('clrq')
    def clrq_must_string(cls, v):
        time.strptime(v, "%Y-%m-%d")
        return str(v)

    @validator('yyqx')
    def yyqx_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('zczb')
    def zczb_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('qylx')
    def qylx_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('xzqhsfmc')
    def xzqhsfmc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('xzqhcsmc')
    def xzqhcsmc_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('zcdz')
    def zcdz_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('jyfw')
    def jyfw_must_string(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator('cjsj')
    def cjsj_must_string(cls, v):
        time.strptime(v, "%Y-%m-%d %H:%M:%S")
        return str(v)


class LgTaoBaoShop(LogosDataDianShangModel):
    """
     淘宝入库验证模型 (Es、MongoDb) -------------------------------------------------------------------------
        序号	字段名称	            字段解释	            数据类型	        是否可空	备注
        001	shop_id	            店铺ID	            整数 - Int	        否	主键
        002	sell_id	            店铺Sell_Id	        整数 - Int	        是
        003	shop_url	        店铺URL	            字符串 - String	    是
        004	shop_name	        店铺名称	            字符串 - String	    是
        005	shop_wangwang	    店铺掌柜旺旺名称	    字符串 - String	    是
        006	phone_list	        店铺联系方式列表	    数组 - List	        是	电话或者座机（必须AES加密，禁止明文）
        007	operating_state 	店铺营业状态	        整数 - Int	        是	1 在营， 0 歇业，-1 关闭
        008	is_enterprise	    是否为企业店铺	        整数 - Int	        是	1 企业店铺， 0 未知， -1非企业店铺
        009	total_sales	        店铺月销量	        整数 - Int	        是	付款人数/下单数量（非总销售额）Sold即可
        010	enterprise_name	    店铺归属企业	        字符串 - String	    是
        011	enterprise_code	    企业社会信用代码	    字符串 - String	    是
        012	province	        店铺归属省份	        字符串 - String	    是
        013	city	            店铺归属城市	        字符串 - String	    是
        014	detailed_address	店铺具体地址	        字符串 - String	    是
        015	start_time	        开店时间	            整数 - Int	        是	转为时间戳
        016	shop_lv	            店铺等级	            整数 - Int	        是	暂留
        017	main_industry	    店铺主营类型	        字符串 - String	    是	暂留
        018	fans	            店铺粉丝数量	        整数 - Int	        是
        019	consumer_deposit	消费者保障金状态	    整数 - Int	        是	1 已缴纳，0 未知 ， -1 未缴纳
        020	total_goods	        宝贝总数	            整数 - Int	        是
        021	favorable_rate	    店铺好评率	        浮点型 - Float	    是	取小数点后两位
        022	ms_rk	            描述评分	            浮点型 - Float	    是	取小数点后两位
        023	fw_rk	            服务评分	            浮点型 - Float	    是	取小数点后两位
        024	wl_rk	            物流评分	            浮点型 - Float	    是	取小数点后两位
        025	ms_compare	        描述比较	            浮点型 - Float	    是	取小数点后两位（大于正数，小于负数）
        026	fw_compare	        服务比较	            浮点型 - Float	    是	取小数点后两位（大于正数，小于负数）
        027	wl_compare	        物流比较	            浮点型 - Float	    是	取小数点后两位（大于正数，小于负数）
        028	shop_rank	        店铺权重评分	        整数 - Int	        是
        029	join_data	        入库时间	            整数时间戳 - Int	    是	转为时间戳
        030	update_data	        更新时间	            整数时间戳 - Int	    是	转为时间戳
        031	historical_data	    近12个月历史更新数据	数组 - List	        是	[{"a":"1","b":"22"}, ....]
        032	other_data	        其他数据	            字典 - Dict	        是
    ----------------------------------------------------------------------------------------------------------------

    """
    shop_id: int = Field()
    sell_id: int = Field(default=None)
    shop_url: str = Field(default=None)
    shop_name: str = Field(default=None)
    shop_wangwang: str = Field(default=None)
    phone_list: list = Field(default=None)
    operating_state: int = Field(default=None)
    is_enterprise: int = Field(default=None)
    total_sales: int = Field(default=None)
    enterprise_name: str = Field(default=None)
    enterprise_code: str = Field(default=None)
    province: str = Field(default=None)
    city: str = Field(default=None)
    detailed_address: str = Field(default=None)
    start_time: int = Field(default=None)
    shop_lv: int = Field(default=None)
    main_industry: str = Field(default=None)
    fans: int = Field(default=None)
    consumer_deposit: int = Field(default=None)
    total_goods: int = Field(default=None)
    favorable_rate: float = Field(default=None)
    ms_rk: float = Field(default=None)
    fw_rk: float = Field(default=None)
    wl_rk: float = Field(default=None)
    ms_compare: float = Field(default=None)
    fw_compare: float = Field(default=None)
    wl_compare: float = Field(default=None)
    shop_rank: int = Field(default=None)
    join_data: int = Field(default=None)
    update_data: int = Field(default=None)
    historical_data: list = Field(default=None)
    other_data: dict = Field(default=None)

    @validator("shop_id")
    def shop_id_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('shop_id value must be int')
        if v < 0:
            raise ValueError('shop_id value must be greater than or equal to zero')
        return int(v)

    @validator("sell_id")
    def sell_id_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('shop_id value must be int')
        if v < 0:
            raise ValueError('shop_id value must be greater than or equal to zero')
        return int(v)

    @validator("shop_url")
    def shop_url_must(cls, v):
        if 'http://' not in v and 'https://' not in v:
            raise ValueError('shop_url value must have http/https')

        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("shop_name")
    def shop_name_must(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("shop_wangwang")
    def shop_wangwang_must(cls, v):
        new_v = v.replace(',', ' ').replace('，', '').replace("'", '').replace('"', '').replace(' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("phone_list")
    def phone_list_must(cls, v):
        if type(v) != list:
            raise ValueError('phone_list value type must a list')
        new_v = v
        return new_v

    @validator("operating_state")
    def operating_state_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('operating_state value must be int')
        if v not in [-1, 0, 1]:
            raise ValueError('operating_state value must be 0, 1, -1')
        return v

    @validator("is_enterprise")
    def is_enterprise_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('is_enterprise value must be int')
        if v not in [-1, 0, 1]:
            raise ValueError('is_enterprise value must be 0, 1, -1')
        return v

    @validator("total_sales")
    def total_sales_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('total_sales value must be int')
        if v < 0:
            raise ValueError('total_sales value must be greater than or equal to zero')
        return v

    @validator("enterprise_name")
    def enterprise_name_must(cls, v):
        new_v = v.replace('(', '（').replace(')', '）').replace(',', ' ').replace('，', '').replace("'", '').replace('"',
                                                                                                                  '').replace(
            ' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("enterprise_code")
    def enterprise_code_must(cls, v):
        new_v = v.replace('(', '（').replace(')', '）').replace(',', ' ').replace('，', '').replace("'", '').replace('"',
                                                                                                                  '').replace(
            ' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("province")
    def province_must(cls, v):
        new_v = v.replace('(', '（').replace(')', '）').replace(',', ' ').replace('，', '').replace("'", '').replace('"',
                                                                                                                  '').replace(
            ' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("city")
    def city_must(cls, v):
        new_v = v.replace('(', '（').replace(')', '）').replace(',', ' ').replace('，', '').replace("'", '').replace('"',
                                                                                                                  '').replace(
            ' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("detailed_address")
    def detailed_address_must(cls, v):
        new_v = v.replace('(', '（').replace(')', '）').replace(',', ' ').replace('，', '').replace("'", '').replace('"',
                                                                                                                  '').replace(
            ' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("start_time")
    def start_time_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('start_time value must be int')
        if v < 0:
            raise ValueError('start_time value must be greater than or equal to zero')
        return v

    @validator("shop_lv")
    def shop_lv_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('shop_lv value must be int')
        if v < 0:
            raise ValueError('shop_lv value must be greater than or equal to zero')
        return v

    @validator("main_industry")
    def main_industry_must(cls, v):
        new_v = v.replace('(', '（').replace(')', '）').replace(',', ' ').replace('，', '').replace("'", '').replace('"',
                                                                                                                  '').replace(
            ' ', ''). \
            replace('\n', '').replace('\r', '').replace('<br/>', '').replace(' ', '').replace('\t', '').strip()
        return new_v

    @validator("fans")
    def fans_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('fans value must be int')
        if v < 0:
            raise ValueError('fans value must be greater than or equal to zero')
        return v

    @validator("consumer_deposit")
    def consumer_deposit_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('fans value must be int')
        if v < 0:
            raise ValueError('fans value must be greater than or equal to zero')
        return v

    @validator("total_goods")
    def total_goods_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('fans value must be int')
        if v < 0:
            raise ValueError('fans value must be greater than or equal to zero')
        return v

    @validator("favorable_rate")
    def favorable_rate_must(cls, v):
        try:
            v = float(v)
        except ValueError:
            raise ValueError('favorable_rate value must be float')
        if v < 0:
            raise ValueError('favorable_rate value must be greater than or equal to zero')
        return v

    @validator("ms_rk")
    def ms_rk_must(cls, v):
        try:
            v = float(v)
        except ValueError:
            raise ValueError('ms_rk value must be float')
        if v < 0:
            raise ValueError('ms_rk value must be greater than or equal to zero')
        return v

    @validator("fw_rk")
    def fw_rk_must(cls, v):
        try:
            v = float(v)
        except ValueError:
            raise ValueError('fw_rk value must be float')
        if v < 0:
            raise ValueError('fw_rk value must be greater than or equal to zero')
        return v

    @validator("wl_rk")
    def wl_rk_must(cls, v):
        try:
            v = float(v)
        except ValueError:
            raise ValueError('wl_rk value must be float')
        if v < 0:
            raise ValueError('wl_rk value must be greater than or equal to zero')
        return v

    @validator("ms_compare")
    def ms_compare_must(cls, v):
        try:
            v = float(v)
        except ValueError:
            raise ValueError('ms_compare value must be float')

        return v

    @validator("fw_compare")
    def fw_compare_must(cls, v):
        try:
            v = float(v)
        except ValueError:
            raise ValueError('fw_compare value must be float')

        return v

    @validator("wl_compare")
    def wl_compare_must(cls, v):
        try:
            v = float(v)
        except ValueError:
            raise ValueError('wl_compare value must be float')

        return v

    @validator("shop_rank")
    def shop_rank_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('shop_rank value must be int')
        if v < 0:
            raise ValueError('shop_rank value must be greater than or equal to zero')
        return v

    @validator("join_data")
    def join_data_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('join_data value must be int')
        if v < 0:
            raise ValueError('join_data value must be greater than or equal to zero')
        return v

    @validator("update_data")
    def update_data_must(cls, v):
        try:
            v = int(v)
        except ValueError:
            raise ValueError('update_data value must be int')
        if v < 0:
            raise ValueError('update_data value must be greater than or equal to zero')
        return v

    @validator("historical_data")
    def historical_data_must(cls, v):
        if type(v) != list:
            raise ValueError('historical_data value must be list')
        return v

    @validator("other_data")
    def other_data_must(cls, v):
        if type(v) != dict:
            raise ValueError('other_data value must be dict')
        return v


if __name__ == '__main__':
    a = LgTaoBaoShop(shop_id=1,
                     )
    print(a.dict(exclude_none=True))
